package com.elvin.platform.webSocket;


import java.net.URI;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *  websocket客户端监听类
 * @author 。
 */
public class BaseWebsocketClient extends WebSocketClient {

  private static Logger logger = LoggerFactory.getLogger(BaseWebsocketClient.class);

  public BaseWebsocketClient(URI serverUri) {
    super(serverUri);
  }

  @Override
  public void onOpen(ServerHandshake serverHandshake) {
    logger.info(">>>>>>>>>>>websocket open");

  }

  @Override
  public void onMessage(String s) {
    logger.info(">>>>>>>>>> websocket message");
    System.out.println(s);

  }

  @Override
  public void onClose(int i, String s, boolean b) {
    logger.info(">>>>>>>>>>>websocket close");
  }

  @Override
  public void onError(Exception e) {
    logger.error(">>>>>>>>>websocket error {}",e);
  }


}
